package com.findFish.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.findFish.common.annotation.Log;
import com.findFish.common.core.controller.BaseController;
import com.findFish.common.core.domain.AjaxResult;
import com.findFish.common.enums.BusinessType;
import com.findFish.system.domain.RobotFishMaintenance;
import com.findFish.system.service.IRobotFishMaintenanceService;
import com.findFish.common.utils.poi.ExcelUtil;
import com.findFish.common.core.page.TableDataInfo;

/**
 * 机器鱼维护记录Controller
 * 
 * @author admin
 * @date 2025-03-31
 */
@RestController
@RequestMapping("/robot/maintenance")
public class RobotFishMaintenanceController extends BaseController
{
    @Autowired
    private IRobotFishMaintenanceService robotFishMaintenanceService;

    /**
     * 查询机器鱼维护记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:list')")
    @GetMapping("/list")
    public TableDataInfo list(RobotFishMaintenance robotFishMaintenance)
    {
        startPage();
        List<RobotFishMaintenance> list = robotFishMaintenanceService.selectRobotFishMaintenanceList(robotFishMaintenance);
        return getDataTable(list);
    }

    /**
     * 导出机器鱼维护记录列表
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:export')")
    @Log(title = "机器鱼维护记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RobotFishMaintenance robotFishMaintenance)
    {
        List<RobotFishMaintenance> list = robotFishMaintenanceService.selectRobotFishMaintenanceList(robotFishMaintenance);
        ExcelUtil<RobotFishMaintenance> util = new ExcelUtil<RobotFishMaintenance>(RobotFishMaintenance.class);
        util.exportExcel(response, list, "机器鱼维护记录数据");
    }

    /**
     * 获取机器鱼维护记录详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(robotFishMaintenanceService.selectRobotFishMaintenanceById(id));
    }

    /**
     * 新增机器鱼维护记录
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:add')")
    @Log(title = "机器鱼维护记录", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RobotFishMaintenance robotFishMaintenance)
    {
        return toAjax(robotFishMaintenanceService.insertRobotFishMaintenance(robotFishMaintenance));
    }

    /**
     * 修改机器鱼维护记录
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:edit')")
    @Log(title = "机器鱼维护记录", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RobotFishMaintenance robotFishMaintenance)
    {
        return toAjax(robotFishMaintenanceService.updateRobotFishMaintenance(robotFishMaintenance));
    }

    /**
     * 删除机器鱼维护记录
     */
    @PreAuthorize("@ss.hasPermi('system:maintenance:remove')")
    @Log(title = "机器鱼维护记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(robotFishMaintenanceService.deleteRobotFishMaintenanceByIds(ids));
    }
}
